/*
 * @Author: xuhong
 * @Date: 2020-04-28 10:56:50
 * @LastEditTime: 2020-04-28 16:31:06
 * @FilePath: \my-admin\src\store\modules\class.js
 */
const cssClass = {
    state: {
        isCollapse: false,
        minLeftMenuWidth: 60,
        maxLeftMenuWidth: 250,
        collapseIcon: true,
        sidebar: {
            opened: true,  
            width: 250
        }
    },
    getters: {
        isCollapse: state => state.isCollapse,
        sidebar: state => state.sidebar,
    },
    mutations: {
        SET_MENU_WHITE: (state) => {
            if(state.sidebar.opened){//true
                state.sidebar.width = state.minLeftMenuWidth;
            }else{
                state.sidebar.width = state.maxLeftMenuWidth;
            }
           state.sidebar.opened = !state.sidebar.opened
        },
        SET_ISCOLLAPSE: (state) => {
            state.isCollapse = !state.isCollapse 
        }
    },
    actions: {
        //菜单收缩 
        clickMenu({commit}){
            commit('SET_ISCOLLAPSE')
        },
        //改变菜单宽度
        clickMenuWhite({commit}){
            commit('SET_MENU_WHITE')
        }
    }
}

export default cssClass